CC = gcc
LD = gcc 
AR = ar
RANLIB = ranlib
STRIP = strip 
CFLAGS  += -O2 -w -Werror -Wno-error=maybe-uninitialized -Wno-error=address-of-packed-member
 

BUILD_DIR=build

# SRC_C=$(wildcard *.c)
SRC_C+=$(wildcard ../libmincrypt/*.c)

 
SRC_C += ../mkbootimg.c 

SRC_MKBOOTIMG=$(SRC_C) 

OBJS_MKBOOTIMG=$(addprefix $(BUILD_DIR)/, $(notdir $(SRC_MKBOOTIMG:.c=.o)))
 
INCLUDE = -I../ -I../include
 
TARGET=mkbootimg
vpath %.c $(sort $(dir $(SRC_MKBOOTIMG)))

.PHONY: all clean

default: all
all:$(BUILD_DIR) $(OBJS_MKBOOTIMG)  $(TARGET)

$(BUILD_DIR):
	mkdir $@
 
$(BUILD_DIR)/%.o:%.c
	@echo CC .c $@ 
	@$(CC) -c $(CFLAGS) $< $(INCLUDE) -o $@

$(TARGET):
	@$(CC)  $(OBJS_MKBOOTIMG) $(CFLAGS) -o $@
	
clean:
	rm -rf $(BUILD_DIR)